export default class PayrollGroup {
    static Keys = {
        ID: 'id',
        NAME: 'name',
        DISBURSEMENT_TYPE: 'disbursement_type',
        NUMBER_OF_MEMBERS: 'number_of_members',
        PAYOUT_SCHEDULES: 'payout_schedules',
        MEMBER_SHARE: 'member_share',
        MINIMUM_PAYOUT_AMOUNT: 'minimum_payout_amount',
        CURRENCY : 'currency',
        TIMESTAMP: 'timestamp',
        TIMESTAMP_LAST_UPDATED: 'timestamp_last_updated'
    }

    id: number;
    name: string;
    disbursementType: number;
    numberOfMembers: number;
    payoutSchedules: number[];
    memberShare: number;
    minimumPayoutAmount: number;
    currency: string;
    timestamp: number;
    timestampLastUpdated: number;

    static fromJSON = (data: {}): PayrollGroup => {
        const group = new PayrollGroup();

        group.id = data[PayrollGroup.Keys.ID];
        group.name = data[PayrollGroup.Keys.NAME];
        group.disbursementType = data[PayrollGroup.Keys.DISBURSEMENT_TYPE];
        group.numberOfMembers = data[PayrollGroup.Keys.NUMBER_OF_MEMBERS];
        group.payoutSchedules = data[PayrollGroup.Keys.PAYOUT_SCHEDULES];
        group.memberShare = data[PayrollGroup.Keys.MEMBER_SHARE];
        group.minimumPayoutAmount = data[PayrollGroup.Keys.MINIMUM_PAYOUT_AMOUNT];
        group.currency = data[PayrollGroup.Keys.CURRENCY];
        group.timestamp = data[PayrollGroup.Keys.TIMESTAMP];
        group.timestampLastUpdated = data[PayrollGroup.Keys.TIMESTAMP_LAST_UPDATED];
        
        return group;
    }
}